package trash;


/**
 * Simple Class for Time Messurements
 * 
 * @author Tim
 * @version 0.4.1
 * @since 0.4.0
 */
public class Stopwatch {

	private long starttime;
	private boolean isRunning = false;
	
	/**
	 * starts the stopwatch, if it is not running already, else does nothing
	 */
	public void start()
	
	{
		if (!isRunning)
		{
			starttime = System.currentTimeMillis();
			isRunning = true;
		}
	}
	
	/**
	 * stops the stopwatch, if it is running, else it does nothing and returns <code>Long.MAX_VALUE</code>
	 * @return the time in milliseconds from starting the stopwatch
	 */
	public long stop()
	{
		if(isRunning)
		{
			isRunning = false;
			return System.currentTimeMillis() - starttime;
		}
		else
		{
			return Long.MAX_VALUE;
		}
	}
	
}
